[Stack Switching] Improve cont.bind fuzzing#8500
[Stack Switching] Improve cont.bind fuzzing#8500kripken wants to merge 18 commits intoWebAssembly:mainfrom
Conversation
kripken
commented
Mar 19, 2026
- Pick a signature from the known interesting types.
- Pick a continuation type using that signature.
src/tools/fuzzing/fuzzing.cpp
Outdated
| auto newCont = Continuation(newSig); | ||
| auto newType = Type(newCont, NonNullable, Exact); | ||
| std::vector<Expression*> newArgs{make(newParam)}; | ||
| auto numOldParams = sig.params.size(); |
There was a problem hiding this comment.
Shouldn't this be numNewParams, since it's the number of parameters of the new continuation cont.bind creates? Maybe "input" and "output" would be clearer than "new" and "old."
There was a problem hiding this comment.
Sounds good, renamed to input/output.
src/tools/fuzzing/fuzzing.cpp
Outdated
| if (pickedSig.results != sig.results) { | ||
| // Results must match. | ||
| continue; | ||
| } |
There was a problem hiding this comment.
WDYT about filtering out impossible signatures before picking? We could memoize the results to avoid pathological repeated work.
There was a problem hiding this comment.
Good idea, and probably fast enough without memoizing. Done.
src/tools/fuzzing/fuzzing.cpp
Outdated
| auto numAddedParams = numNewParams - numOldParams; | ||
| bool bad = false; | ||
| for (Index i = 0; i < numOldParams; i++) { | ||
| if (pickedSig.params[numAddedParams + i] != sig.params[i]) { |
There was a problem hiding this comment.
This should allow for subtyping in one direction or the other. The params of the output signature should be subtypes of the corresponding params of the input signature.
src/tools/fuzzing/fuzzing.cpp
Outdated
| if (numinputParams < numOutputParams) { | ||
| // Too short. | ||
| continue; | ||
| } | ||
| // Ignoring the input params at the start, compare the tails. | ||
| auto numAddedParams = numinputParams - numOutputParams; | ||
| bool bad = false; | ||
| for (Index i = 0; i < numOutputParams; i++) { | ||
| if (!Type::isSubType(outputSig.params[i], | ||
| pickedSig.params[numAddedParams + i])) { | ||
| bad = true; | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
This filtering can be moved up, too. Then we won't need to try to find an appropriate signature multiple times at all.